﻿using DotSpatial.Controls;
using DotSpatial.Data;
using DotSpatial.Symbology;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KASEM
{
    public partial class Form2 : Form
    {
        FeatureLayer FeLyr;
        ISelection selFe;
        FeatureSet Fe;

        Map mainMap;
        public Map MainMap
        {
            get { return mainMap; }
            set { mainMap = value; }
        }
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
           FeLyr = MainMap.Layers[0] as FeatureLayer;
           selFe = FeLyr.Selection;
           Fe =  selFe.ToFeatureSet(); 
           dataGridView1.DataSource = Fe.DataTable;
           label1.Text = "Number of selected shapes are: "+Fe.NumRows().ToString();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            grdGeometry.Rows.Clear();
            IFeature fe = Fe.GetFeature(row);
            label2.Text = "Record no. " + fe.RecordNumber.ToString()  ;  
            for (int pt = 0; pt < fe.NumPoints;pt++ )
            {
                int activeRow = grdGeometry.Rows.Add();
                grdGeometry.Rows[activeRow].Cells[0].Value = fe.Coordinates[pt].X;// BasicGeometry.Coordinates[pt].X;
                grdGeometry.Rows[activeRow].Cells[1].Value = fe.Coordinates[pt].Y;// BasicGeometry.Coordinates[pt].Y;
            }
        }

    }
}
